package server;

import test.Main;
import maze.*;

public class Game {
	
	Maze maze = null;
	public Game() {
		this.maze = createMaze();
	}
	
	private Maze createMaze() {
		Maze newMaze = new Maze();
		newMaze.entry.name = "A4";
		Room a3 = newMaze.entry.createNorth("A3");
		Room b3 = a3.createEast("B3");
		Room b4 = b3.createSouth("B4");
		Room c3 = b3.createEast("C3");
		Room c4 = c3.createSouth("C4");
		Room d3 = c3.createEast("D3");
		Room d4 = d3.createSouth("D4").createExit();
		Room c2 = c3.createNorth("C2");
		Room c1 = c2.createNorth("C1");
		Room d1 = c1.createEast("D1");
		Room d2 = d1.createNorth("D2").createPortal(false, d3);
		Room b2 = c2.createWest("B2");
		Room a2 = b2.createWest("A2").createExit();
		Room b1 = b2.createNorth("B1");
		Room a1 = b1.createWest("A1").createPortal(true, c4);
		return newMaze;
	}
	
	public Player createNewPlayer() {
		Player player = new Player();
		player.Enter(maze);
		return player;
	}
	
	public void endThisPart(Player pl) {
		startNewPart();
	}
	
	public void startNewPart() {
		try {
			Main.server = new Communications();
			Main.server.setConnection();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
